**********************************************************************
* Replication Code for Main Results for General Election (Study 2)   *
**********************************************************************
* Ahler, Citrin, Dougal, and Lenz (2016)


***************************************************
*    Figure 3:  Main Aggregate Scatterplot        *
***************************************************
*"Fig. 3 Appearance-Advantaged Candidates in Statewide General Elections Benefit in Photo Condition"

clear all
use racelevelfacesdata_study2.dta

	scatter vote_difference_R face_difference_R [aw =race_vt], yline(0)  || lfit vote_difference_R face_difference_R [aw =race_vt ],legend(off) scheme(lean2) yl(, nogrid)   xt("Appearance advantage (for Republican candidate)") yt("Photo condition - no-photo condition vote share" "(for Republican candidate)") text(-0.15 0.875 "Slope = 0.20") text(-0.18 0.875 "(95% CI 0.05 to 0.35)") 
    graph export fig3mainaggregateplot.png,width(3200)  height(2400)  replace
	
***************************************************
*          Table 2 Main Aggregate Results         *
***************************************************
*"Table 2: Appearance-Advantaged Candidates in Statewide General Elections Benefit in Photo Condition"
clear all
use racelevelfacesdata_study2.dta


***Main Regression
	regress vote_difference_R face_difference_R [aw =race_vt] 
	outreg2 using Table2, word se dec(2) replace
***Matched on Race and Gender	
	regress vote_difference_R face_difference_R if matched_rg == 1 [aw =race_vt]
	outreg2 using Table2, word se dec(2) append
***Controlling for Race, Gender, and Incumbency
	regress vote_difference_R face_difference_R _inc _female* _white* [aw =race_vt]
	outreg2 using Table2, word se dec(2) append 
***Senate Races
	regress vote_difference_R face_difference_R if  officelabel == "Sen" | officelabel == "Gov" [aw =race_vt]
	outreg2 using Table2, word se dec(2) append 
**Non-Senate Races
	regress vote_difference_R face_difference_R if  officelabel != "Sen" & officelabel != "Gov"   [aw =race_vt]
	outreg2 using Table2, word se dec(2) append

*Races where min_rating <= 25th percentile	
	regress vote_difference_R face_difference_R [aw =race_vt] if min_rating <= facep25
	outreg2 using Table2, word se dec(2) append 
*Races where min_rating > 25th percentile	
	regress vote_difference_R face_difference_R [aw =race_vt] if min_rating > facep25
	outreg2 using Table2, word se dec(2) append 

*In text analysis based on Table 2
*robustness to particular cases
 generate case =_n
	for num 1/43: regress vote_difference_R face_difference_R [aw =race_vt] if case!=X

***Effect of one-SD change in face_difference:
sum face_difference_R
	/* SD(face_difference_R) = 0.197 */
display 0.201 * 0.197 /* 1 SD improvement in face_difference_R boosts GOP vote share 0.0395, or 4.0 percentage points */

***********************************************************************************
*      Table 3 Invididual Level Results (without fixed effects)                   *
***********************************************************************************
*"Table 3: Voters Favor Appearance-Advantaged Candidates at Higher Rates on the Photo Ballot"

clear all
use individualfacesdata_study2.dta

***Main Regression - no fixed effects
	cluster2 vote_R treatment face_difference_R  t_x_face_difference_R, fcluster(cid0) tcluster(respondentID)
	outreg2 using Table3, word se dec(2) replace
    *how many races? 43
***Matched on Race and Gender
	cluster2 vote_R treatment face_difference_R t_x_face_difference_R if matched_rg == 1, fcluster(cid0) tcluster(respondentID)
	outreg2  using Table3, word se dec(2) append
***Low Knowledge
	cluster2 vote_R treatment face_difference_R t_x_face_difference_R   if know<=2, fcluster(cid0) tcluster(respondentID)
	outreg2  using Table3, word se dec(2) append
***High Knowledge
	cluster2 vote_R treatment face_difference_R t_x_face_difference_R  if know>2, fcluster(cid0) tcluster(respondentID)
	outreg2  using Table3, word se dec(2) append 
***Weak Partisans and Independents
	cluster2 vote_R treatment face_difference_R t_x_face_difference_R  if strongp==0, fcluster(cid0) tcluster(respondentID)
	outreg2  using Table3, word se dec(2) append
***Stong Partisan
	cluster2 vote_R treatment face_difference_R t_x_face_difference_R if strongp==1, fcluster(cid0) tcluster(respondentID)
	outreg2 using Table3, word se dec(2) append 


	 
	
********************************************************************************
*           Table 4 PID vs. Knowledge (Without Fixed Effects)                  *
********************************************************************************
*"Table 4: Low-Information Voters are Most Susceptible to Candidate Appearance"
clear all
use individualfacesdata_study2.dta

***Low Knowledge & Non-Strong Partisan
	cluster2 vote_R treatment face_difference_R t_x_face_difference_R  if strongp==0 & know<=2, fcluster(cid0) tcluster(respondentID)
	outreg2 using Table4, word se dec(2) replace
***Low Knowledge & Strong Partisan
	cluster2 vote_R treatment face_difference_R t_x_face_difference_R  if strongp==1 & know<=2, fcluster(cid0) tcluster(respondentID)
	outreg2 using Table4, word se dec(2) append
***High Knowledge & Non-Strong Partisan
	cluster2 vote_R treatment face_difference_R t_x_face_difference_R  if strongp==0 & know>2 & know <., fcluster(cid0) tcluster(respondentID)
	outreg2 using Table4, word se dec(2) append	
***High Knowledge & Strong Partisan
	cluster2 vote_R treatment face_difference_R t_x_face_difference_R  if strongp==1 & know>2 & know <., fcluster(cid0) tcluster(respondentID)
	outreg2 using Table4, word se dec(2) append
